package com.wms.controller;


 import io.swagger.annotations.Api;
 import lombok.Data;
 import org.springframework.web.bind.annotation.*;

 import javax.servlet.http.HttpSession;

/**
 * <p>
 * 前端控制器erg sd
 * </p>
 *
 * @author liangzai
 * @since 2023-11-09
 */
@RestController
@RequestMapping("/api")
@Api(value = "AxiosController", tags = "AxiosController")

public class AxiosController {


    @GetMapping("/a1")
    @CrossOrigin("http:localhost:")
    public String a1() {
        return "get request";
    }


    @PostMapping("/a2")
    public String a2() {
        return "post request";
    }


    @PostMapping("/a3")
    public String a3(@RequestHeader("token") String token) {
        return "post request";
    }

    @PostMapping("/a4")
    public String a4(String name, Integer age) {
        System.out.println("name=" + name + "age=" + age);
        return "post request";
    }


    @PostMapping("/a5")
    public String a5(A5 a5) {
        System.out.println(a5);
        return "post request";
    }


    @PostMapping("/a5json")
    public String a5json(@RequestBody A5 a5) {
        System.out.println(a5);
        return "post request";
    }


    @PostMapping("/a6set")
    public String a6set(HttpSession session) {
        System.out.println("=====a6 set =======");
        System.out.printf(session.getId());
        session.setAttribute("name","老雷");
        return "post request";
    }


    @PostMapping("/a6get")
    public String a6get(HttpSession session) {
        System.out.println("=====  a6get =======");
        System.out.printf(session.getId());
        System.out.printf("name=" + session.getAttribute("name"));

        return "post request";
    }


    @Data
    private static class A5 {
      private   String name ;
        private Integer age;
    }
}
